www.gusucode.com > VC++仿XP免费Prof UIS界面库-源码程序 > VC++仿XP免费Prof UIS界面库-源码程序/code/Samples/ResizableChildSheet/ResizableChildSheet.cpp
//Download by http://www.NewXing.com // ResizableChildSheet.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "ResizableChildSheet.h" #include "MainFrm.h" #include "ChildFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDemoApp BEGIN_MESSAGE_MAP(CDemoApp, CWinApp) //{{AFX_MSG_MAP(CDemoApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_FILE_NEW, OnFileNew) ON_COMMAND(ID_VIEW_UI_STYLE_2K, OnViewLikeOffice2k) ON_UPDATE_COMMAND_UI(ID_VIEW_UI_STYLE_2K, OnUpdateViewLikeOffice2k) ON_COMMAND(ID_VIEW_UI_STYLE_XP, OnViewLikeOfficeXp) ON_UPDATE_COMMAND_UI(ID_VIEW_UI_STYLE_XP, OnUpdateViewLikeOfficeXp) ON_COMMAND(ID_VIEW_LIKE_OFFICE_2003, OnViewLikeOffice2003) ON_UPDATE_COMMAND_UI(ID_VIEW_LIKE_OFFICE_2003, OnUpdateViewLikeOffice2003) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDemoApp construction CDemoApp::CDemoApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CDemoApp object CDemoApp theApp; ///////////////////////////////////////////////////////////////////////////// // Prof-UIS advanced options void CDemoApp::SetupUiAdvancedOptions() { VERIFY( g_CmdManager->ProfileSetup( __PROF_UIS_PROJECT_CMD_PROFILE_NAME ) ); g_PaintManager.InstallPaintManager( new CExtPaintManager ); CExtPopupMenuWnd::g_bMenuExpanding = false; CExtPopupMenuWnd::g_bMenuHighlightRarely = false; } ///////////////////////////////////////////////////////////////////////////// // CDemoApp initialization BOOL CDemoApp::InitInstance() { // // Prof-UIS advanced options // SetupUiAdvancedOptions(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey( _T("Prof-UIS Application Wizard Generated Applications") ); ASSERT( m_pszRegistryKey != NULL ); // Change the application profile name (usually product name). // NOTE: The CWinApp class destructor will free the memory automatically. if( m_pszProfileName != NULL ) free( (void*)m_pszProfileName ); m_pszProfileName = _tcsdup( _T("ResizableChildSheet") ); ASSERT( m_pszProfileName != NULL ); // To create the main window, this code creates a new frame window // object and then sets it as the application's main window object. CMDIFrameWnd* pFrame = new CMainFrame; m_pMainWnd = pFrame; // create main MDI frame window if( !pFrame->LoadFrame(IDR_MAINFRAME) ) return FALSE; // try to load shared MDI menus and accelerator table //TODO: add additional member variables and load calls for // additional menu types your application may need. HINSTANCE hInst = AfxGetResourceHandle(); m_hMDIMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_CHILDSTYPE)); m_hMDIAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_CHILDSTYPE)); // The main window has been initialized, so show and update it. pFrame->ActivateFrame( m_nCmdShow ); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CDemoApp message handlers int CDemoApp::ExitInstance() { //TODO: handle additional resources you may have added if (m_hMDIMenu != NULL) FreeResource(m_hMDIMenu); if (m_hMDIAccel != NULL) FreeResource(m_hMDIAccel); return CWinApp::ExitInstance(); } void CDemoApp::OnFileNew() { CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd); // create a new MDI child window pFrame->CreateNewChild( RUNTIME_CLASS(CChildFrame), IDR_CHILDSTYPE, m_hMDIMenu, m_hMDIAccel); } ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CExtResizableDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; CExtButton m_BtnOK; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CExtResizableDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CExtResizableDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) DDX_Control(pDX, IDOK, m_BtnOK); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CExtResizableDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() BOOL CAboutDlg::OnInitDialog() { VERIFY( CExtResizableDialog::OnInitDialog() ); // // Show size gripper // CExtResizableDialog::ShowSizeGrip( FALSE ); // // Enable dialog position saving/restoring in registry // CExtResizableDialog::EnableSaveRestore( __PROF_UIS_PROJECT_DLG_PERSIST_REG_KEY, _T("CAboutDlg-Saved-Position") ); // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } // App command to run the dialog void CDemoApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } ///////////////////////////////////////////////////////////////////////////// // CDemoApp message handlers void CDemoApp::OnViewLikeOffice2k() { if( !g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) ) ) return; VERIFY( g_PaintManager.InstallPaintManager( new CExtPaintManager ) ); CWnd * pWndMain = ::AfxGetMainWnd(); if( pWndMain->GetSafeHwnd() == NULL ) return; CMainFrame * pFrame = STATIC_DOWNCAST( CMainFrame, pWndMain ); ASSERT_VALID( pFrame ); pFrame->RecalcLayout(); pFrame->RedrawWindow( NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN ); CExtControlBar::stat_RedrawFloatingFrames( pFrame ); CExtControlBar::stat_RecalcBarMetrics( pFrame ); } void CDemoApp::OnUpdateViewLikeOffice2k(CCmdUI* pCmdUI) { pCmdUI->Enable(); pCmdUI->SetRadio( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) ) ? FALSE : TRUE ); } void CDemoApp::OnViewLikeOfficeXp() { if( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) ) && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) ) ) return; VERIFY( g_PaintManager.InstallPaintManager( new CExtPaintManagerXP ) ); CWnd * pWndMain = ::AfxGetMainWnd(); if( pWndMain->GetSafeHwnd() == NULL ) return; CMainFrame * pFrame = STATIC_DOWNCAST( CMainFrame, pWndMain ); ASSERT_VALID( pFrame ); pFrame->RecalcLayout(); pFrame->RedrawWindow( NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN ); CExtControlBar::stat_RedrawFloatingFrames( pFrame ); CExtControlBar::stat_RecalcBarMetrics( pFrame ); } void CDemoApp::OnUpdateViewLikeOfficeXp(CCmdUI* pCmdUI) { pCmdUI->Enable(); pCmdUI->SetRadio( ( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) ) && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) ) ) ? TRUE : FALSE ); } void CDemoApp::OnViewLikeOffice2003() { if( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) ) return; VERIFY( g_PaintManager.InstallPaintManager( new CExtPaintManagerOffice2003 ) ); CWnd * pWndMain = ::AfxGetMainWnd(); if( pWndMain->GetSafeHwnd() == NULL ) return; CMainFrame * pFrame = STATIC_DOWNCAST( CMainFrame, pWndMain ); ASSERT_VALID( pFrame ); pFrame->RecalcLayout(); pFrame->RedrawWindow( NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN ); CExtControlBar::stat_RedrawFloatingFrames( pFrame ); CExtControlBar::stat_RecalcBarMetrics( pFrame ); } void CDemoApp::OnUpdateViewLikeOffice2003(CCmdUI* pCmdUI) { pCmdUI->Enable(); pCmdUI->SetRadio( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) ? TRUE : FALSE ); }